import { BroadCastCall } from "../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../Framework/MQ/MessageBlock";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { AutoFight } from "../../view/autoFight/AutoFight";
import { SPacket } from "../../../../Message/Public/SPacket";
import { ItemConfig } from "../../resource/ItemConfig";
import { ECategory } from "../../../../Message/Public/ECategory";
import { GameProxy } from "../../mvc/GameProxy";
//class EntityDropItemCommand
    
    export  class EntityDropItemCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc7=null;
            var loc8=false;
            NetDispatcher.dispatchCmd(arg1.messageHead.command, arg1);
            if (AutoFight.currentAutoFight.isAutoFight && AutoFight.currentAutoFight.pickThing) 
            {
                loc1 = arg1.messageBase as SPacket;
                loc2 = new Map<any, any> /* flash.utils.Dictionary */();
                loc3 = 0;
                var loc9=0;
                var loc10=loc1.playerItem;
                for(loc5 of loc10) 
                {
                    if ((loc4 = ItemConfig.instance.getInfoByCode(loc5.itemCode).item).category == ECategory._ECategoryEquip) 
                    {
                        if (AutoFight.currentAutoFight.pickEquip == 0 || loc4.color >= AutoFight.currentAutoFight.pickEquip) 
                        {
                            if (AutoFight.currentAutoFight.careerEquip == 0 || AutoFight.currentAutoFight.careerEquip & loc4.career) 
                            {
                                loc2[loc5.uid] = 0;
                                ++loc3;
                            }
                        }
                        continue;
                    }
                    loc6 = AutoFight.currentAutoFight.pickDrug;
                    loc8 = true;
                    if (loc6.length > 0) 
                    {
                        var loc11=0;
                        var loc12=loc6;
                        for(loc7 of loc12) 
                        {
                            if (!(loc4.category == loc7.category && loc4.type == loc7.type)) 
                            {
                                continue;
                            }
                            if (!(loc7.effectEx <= 0 || loc7.effectEx == loc4.effectEx)) 
                            {
                                continue;
                            }
                            loc8 = false;
                        }
                    }
                    if (loc8 == false) 
                    {
                        continue;
                    }
                    if ((loc6 = AutoFight.currentAutoFight.pickOtherThings).length > 0) 
                    {
                        loc11 = 0;
                        loc12 = loc6;
                        for(loc7 of loc12) 
                        {
                            if (!(loc4.category == loc7.category && loc4.type == loc7.type)) 
                            {
                                continue;
                            }
                            if (!(loc7.effectEx <= 0 || loc7.effectEx == loc4.effectEx)) 
                            {
                                continue;
                            }
                            loc8 = false;
                        }
                    }
                    if (loc8 == false) 
                    {
                        continue;
                    }
                    loc2[loc5.uid] = 0;
                    ++loc3;
                }
                if (loc3 > 0) 
                {
                    GameProxy.sceneProxy.autoPickItems(loc1.entityId, loc2);
                }
            }
            return;
        }
    }
